package com.orderMeal.business.authority.action;



import java.util.List;

import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import com.orderMeal.business.authority.model.AdminUser;
import com.orderMeal.business.authority.service.UserService;
import com.orderMeal.common.action.BaseAction;

@Controller("adminUserAction")
public class AdminUserAction extends BaseAction{
	private static final long serialVersionUID = 1L;
	@Resource(name="userService")
	private UserService userService;
	private AdminUser admin_user;
	public String showAdminUsers(){
		List list = userService.queryAll(" from AdminUser");
		AdminUser u =null;
		for (int i = 0; i < list.size(); i++) {
			 u = (AdminUser)list.get(i);
		}
		super.setRequestAttribute("adminUserList", list);
		return "show";
	}
	public String deleteAdminUsers(){
		userService.delete(admin_user);
		return showAdminUsers();
	}
	
	public String saveAdminUsers(){
		userService.editSave(admin_user);
		return showAdminUsers();
	}
	
	public String addAdminUsers(){
		String flag = super.getRequestParameter("flag");
		if(flag!=null&&flag.equals("add")){
			userService.editSave(admin_user);
			return showAdminUsers();
		}else if(flag!=null&&flag.equals("toAdd")){
			return "success";
		}
		return showAdminUsers();
	}
	
	
	
	
	public AdminUser getAdmin_user() {
		return admin_user;
	}
	public void setAdmin_user(AdminUser admin_user) {
		this.admin_user = admin_user;
	}
	
}
